package ccgl.com.util;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 *得到paramConfig.properties文件的值
 * @author wei
 *
 */
public class ParamConfigParameters {
	//文件路径
	String configFilePath = "dbconfig.properties";
	Properties properties = null;
	private InputStream in;

	public ParamConfigParameters() {
		File f = new File(configFilePath);
		properties = new Properties();
		in = ParamConfigParameters.class.getClassLoader().getResourceAsStream(configFilePath);
		try {
			properties.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public String getParameter(String key) {
		return properties.getProperty(key);
	}
	
	public void closeResource() {
		try {
			in.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		properties.clear();
	} 
	
	/**
	 *@author wei
	 *@version 创建时间:2014-3-16下午05:56:33
	 *@param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ParamConfigParameters p = new ParamConfigParameters();
		System.out.println(p.getParameter("driver-class"));
		p.closeResource();
	}

}
